package com.evan.common;

import com.evan.common.dao.ZkServerDao;
import com.evan.common.pojo.Cluster;
import com.evan.common.pojo.ZkServerInfo;
import com.evan.common.service.ClusterService;
import com.evan.common.service.ZkServerService;
import com.evan.common.service.impl.ClusterServiceImpl;
import com.evan.common.service.impl.ZkServerServiceImpl;
import org.junit.jupiter.api.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class Scheduler {

    @Test
    public void getZkInfoInCluster() throws InvocationTargetException, IllegalAccessException {
        Integer cid = 1;
        ZkServerService zs = new ZkServerServiceImpl();
        ClusterService cs = new ClusterServiceImpl();
        Method[] methods = ZkServerDao.class.getMethods();
        for (Method method : methods) {
            if(method.getName().equals("findAllByClusterId")){
                Cluster res = (Cluster) method.invoke(cid);
                System.out.println(res);
            }else{return;}
        }


//        Map<String,List<ZkServerInfo>> os = new HashMap<>();
//
//        List<ZkServerInfo> nodeByClusterId = zs.getZkNodeByClusterId(cid);
//        Optional<Cluster> allCluster = cs.getClusterByCid(cid);
//        Cluster cluster = allCluster.get();
//
//        os.put(cluster.getClusterName(),nodeByClusterId);
//        System.out.println(os);
    }

}
